home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / -archivi / -recent2 / gaplib.lha / GAPLib_Beta / doc / text / GAP.doc next >
Text File  |  1999-03-12  |  22KB  |  754 lines

  1. TABLE OF CONTENTS
  2.  
  3. GAP.lib/--background--
  4. GAP.lib/--data items--
  5. GAP.lib/CreatePopulation
  6. GAP.lib/Crossover
  7. GAP.lib/DeletePopulation
  8. GAP.lib/EnterGAP
  9. GAP.lib/Evolve
  10. GAP.lib/Flip
  11. GAP.lib/GaussRand
  12. GAP.lib/HammingDist
  13. GAP.lib/InitRand
  14. GAP.lib/InRand
  15. GAP.lib/IRange
  16. GAP.lib/PopMember
  17. GAP.lib/Rnd
  18. GAP.lib/Testbit
  19.  
  20.  
  21. GAP.lib/--background--                                   GAP.lib/--background--
  22.  
  23.    PURPOSE
  24.     The Genetic Algorithm Programming Library (GAP-Lib) is intended to
  25.     make it easier to implement genetic algorithms for any purpose. The
  26.     library itself implements most of the framework needed to handle one
  27.     or several populations thus leaving the programmer free to concentrate
  28.     on the purpose of her program.
  29.     Some work will still be needed, specifically setting up a genotype,
  30.     creating a fitness function and in some cases functions for
  31.     initializing, mutating, crossing and deleting individuals.
  32.  
  33.    OVERVIEW
  34.     GAP-Lib: A Genetic Algorithm Programming Library.
  35.  
  36.     A library for programming with genetic algorithms. The library features
  37.     a simple yet flexible interface coupled with sensible default values
  38.     and quite powerful built-in functionality to provide for both high and
  39.     low-level programming.
  40.  
  41.     The GAP-Lib is primarily bit-oriented and this is reflected in the
  42.     existing default-functions for crossover and  mutation. It is however
  43.     possible to use almost any representation as long as the library
  44.     itself only sees fixed-length individuals (Variable length individuals
  45.     are possible though).
  46.  
  47.     A typical program using the GAP-Lib will begin by initializing the
  48.     GAP environment by calling EnterGAP() then create a population using
  49.     CreatePopulation() followed by some number of calls to Evolve() and
  50.     finally ending with calling DeletePopulation().
  51.  
  52.     The current version as of 12-Mar-1999 is 0.74
  53.     (Version 0, Revision 74).
  54.  
  55.     Current limitations include:
  56.  
  57.     · Not thread-safe (Not dynamically linked).
  58.     · Need to implement variable-length individuals manually.
  59.     · No special support for geographical environments.
  60.     · No special support for parallell implementations.
  61.  
  62.  
  63. GAP.lib/--data items--                                   GAP.lib/--data items--
  64.  
  65.    STRUCTURES
  66.     GAP-Lib has three primary structures to keep track of data. One is the
  67.     user-defined structure which describes an individual and though this
  68.     structure is not always nessecary, it is highly recommended that you
  69.     have one since it will help others to read your code.
  70.  
  71.     The other structure is the population structure which in turn includes
  72.     a statistics structure. A member-by-member explanation of these
  73.     structures follow here:
  74.  
  75.     struct Population {
  76.        long   NumPolys;
  77.        long   Generation;
  78.        long   Flags;
  79.        struct Popstat Stat;
  80.        long   Bytes;
  81.        void  *Polys;
  82.        void  *Magic;
  83.     };
  84.  
  85.     NumPolys - This is the number of individuals in the population.
  86.     Generation - This is how many times a generation shift has taken place.
  87.     Flags - Internal status, do not touch.
  88.     Stat - This is the statistics structure, see below.
  89.     Bytes - Bytes per individual.
  90.     Polys - This is for the internal list of individuals, do not touch.
  91.     Magic - This is also internal, do not touch.
  92.  
  93.     struct Popstat {
  94.        double  AverageFitness;
  95.        double  MedianFitness;
  96.        double  TypeFitness;
  97.        long    TypeCount;
  98.        double  StdDeviation;
  99.        double  MaxFitness;
  100.        double  MinFitness;
  101.        void   *Max;
  102.        long    Generation;
  103.     };
  104.  
  105.     AverageFitness - The average fitness of the population.
  106.     MedianFitness - The median fitness of the population.
  107.     TypeFitness - The type (most common) fitness value.
  108.     TypeCount - The number of individuals with the type fitness.
  109.     StdDeviation - The standard deviation of the fitness values.
  110.     MaxFitness - The fitness value of the fittest individual.
  111.     MinFitness - The fitness value of the least fit individual.
  112.     Max - A pointer to the fittest individual after the last call to
  113.           Evolve().
  114.     Generation - The generation for which these statistics are valid.
  115.  
  116.     The Popstat structure is read-only and it is important to remember
  117.     that even if you copy the structure the Max pointer will become
  118.     invalid the next time Evolve() is called.
  119.  
  120.    TAGLISTS
  121.     A taglist is a list of pairs, the first member of the pair is the
  122.     tag and determines what type of data the second member is. A typical
  123.     member of a taglist could look like this:
  124.  
  125.     {EVL_Elite,5}
  126.      ^         ^
  127.      |       |-> The data.
  128.      |-> The type of data.
  129.  
  130.     A complete taglist could look like this:
  131.  
  132.     struct TagItem MyTaglist[]={
  133.        {EVL_Evaluator, fitfunc}, /* Fitness function */
  134.        {EVL_Elite,     5}, /* No. of elite individuals */
  135.        {TAG_DONE,      0}  /* End-Tag */
  136.     };
  137.  
  138.     The End-Tag, TAG_DONE, is a special tag common to all taglists. There
  139.     are currently four such tags defined:
  140.  
  141.     TAG_DONE    - Marks the end of a taglist.
  142.     TAG_END        - Equivalent to TAG_DONE.
  143.     TAG_IGNORE    - This tag is ignored.
  144.     TAG_MORE    - ti_Data is a pointer to a taglist with more tags,
  145.               processing of the current taglist will be terminated.
  146.  
  147.     As some of you might be a bit lazy ;-), there is also an alternative
  148.     way of specifying taglists. At least in GAP-Lib there is. As an example
  149.     we have the function Evolve() which also has and interface named
  150.     EvolveT(), EvolveT() takes a variable number of arguments, the last
  151.     of which make up the taglist. To use the above taglist with EvolveT()
  152.     one would write:
  153.  
  154.     EvolveT(Pop,EVL_Evaluator,fitfunc,EVL_Elite,5,TAG_DONE);
  155.         ^
  156.         |->This is not part of the taglist.
  157.  
  158.    PRIMITIVE TYPES
  159.     GAP-Lib defines one primitive data type; IPTR. The IPTR is a type
  160.     large enough to hold both an integer and a pointer, it is used for
  161.     the data-part of a tagitem. IPTR can be considered equivalent to
  162.     intptr_t as defined in the C9X ISO C-Language standard-to-be.
  163.  
  164.  
  165. GAP.lib/CreatePopulation                               GAP.lib/CreatePopulation
  166.  
  167.    NAME
  168.     CreatePopulation -- Allocates and initializes a population.
  169.     CreatePopulationT -- Varargs interface to CreatePopulation.
  170.  
  171.    SYNOPSIS
  172.     struct Population *CreatePopulation(long int,long int,struct TagItem *)
  173.     struct Population *CreatePopulationT(long int,long int,...);
  174.  
  175.     Pop = CreatePopulation(Num,PSize,TagList);
  176.     Pop = CreatePopulationT(Num,PSize,...);
  177.  
  178.    FUNCTION
  179.     This function will allocate and initialize a population. If no
  180.     initialization function is given, CreatePopulation() will simply
  181.     randomize all bits in the created individuals. There is also a
  182.     predefined initialization function which initializes every individual
  183.     to a string of zero bits.
  184.  
  185.    INPUTS
  186.     Num     - Number of individuals to be created in this population.
  187.     PSize     - The byte-size of the individuals in this population.
  188.     TagList  - A pointer to a taglist.
  189.  
  190.    TAGS
  191.     POP_Init (void (*)(void *)) - A pointer to a function or one of the
  192.          values RAND_INIT or ZERO_INIT. Currently NULL is equivalent to
  193.          ZERO_INIT. A function to initialize an individual should take a
  194.          pointer to an individual and return nothing (void).
  195.  
  196.     POP_Destruct (void (*)(void *)) - A pointer to a function to be called
  197.          when deleting an individual. If you are allocating resources with
  198.          a custom initialization function, then you should supply this
  199.          tag. The function should take a pointer to an individual and
  200.          return nothing (void).
  201.  
  202.     POP_Cache (BOOL) - Set this to false if you are modifying the
  203.          individuals between calls to Evolve() or if you really need to
  204.          save memory. Default is TRUE which enables some caching of data.
  205.  
  206.    RESULT
  207.     Pop     - An initialized population structure or NULL if something
  208.            failed.
  209.  
  210.    NOTE
  211.     CreatePopulation() could fail if EnterGAP() has not been called
  212.     previously (Currently not).
  213.  
  214.    BUGS
  215.     None known.
  216.  
  217.    SEE ALSO
  218.     EnterGAP(), DeletePopulation()
  219.  
  220.  
  221. GAP.lib/Crossover                                             GAP.lib/Crossover
  222.  
  223.    NAME
  224.     Crossover -- Perform crossover on two bitstrings.
  225.  
  226.    SYNOPSIS
  227.     void Crossover(void *,void *,int,int);
  228.  
  229.     Crossover(void *Ind1,void *Ind2,int At,int Size);
  230.  
  231.    FUNCTION
  232.     Performs one-point crossover of two bitstrings. The bitstrings must
  233.     have the same length.
  234.  
  235.    INPUTS
  236.     Ind1    - Pointer to the first bitstring (Individual).
  237.     Ind2    - Pointer to the second bitstring (Individual).
  238.     At    - Bit to perform crossover at.
  239.     Size    - Size of bitstring in bytes. (OBS!: _BYTES_!!)
  240.  
  241.    RESULT
  242.     None.
  243.  
  244.    NOTE
  245.     Note well that all bitstrings must consist of a whole number of bytes.
  246.     This is for reasons of simplicity and efficiency.
  247.  
  248.    BUGS
  249.     None known.
  250.  
  251.    SEE ALSO
  252.     Flip
  253.  
  254.  
  255. GAP.lib/DeletePopulation                               GAP.lib/DeletePopulation
  256.  
  257.    NAME
  258.     DeletePopulation -- Delete a previously allocated population.
  259.  
  260.    SYNOPSIS
  261.     void DeletePopulation(struct Population *);
  262.  
  263.     DeletePopulation(Pop);
  264.  
  265.    FUNCTION
  266.     Deletes a previously allocated population and frees all resources
  267.     associated with it. If no custom deallocation function was given only
  268.     the resources allocated by CreatePopulation() will be freed (If 
  269.     CreatePopulation() was called without a custom initialization function,
  270.     this is probably what you want).
  271.  
  272.    INPUTS
  273.     Pop    - Pointer to the population to be deleted.
  274.  
  275.    RESULT
  276.     None.
  277.  
  278.    BUGS
  279.     None known.
  280.  
  281.    SEE ALSO
  282.     CreatePopulation()
  283.  
  284.  
  285. GAP.lib/EnterGAP                                               GAP.lib/EnterGAP
  286.  
  287.    NAME
  288.     EnterGAP -- Initialize GAP environment.
  289.  
  290.    SYNOPSIS
  291.     void EnterGAP(int Level);
  292.  
  293.     EnterGAP(Level);
  294.  
  295.    FUNCTION
  296.     Initializes the GAP environment.
  297.  
  298.    INPUTS
  299.     Level    - Level of verbosity at startup, supported values range from
  300.           0 to 2 with 0=Quiet, 1=Normal, 2=Verbose.
  301.  
  302.    RESULT
  303.     0 for failure, non-zero for success.
  304.  
  305.    EXAMPLE
  306.     int main(void)
  307.     {
  308.         /* Do some stuff here */
  309.     ...
  310.     if(EnterGAP(1)) {
  311.     ...
  312.     ...    /* Do everything here. */
  313.     ...
  314.     } else {
  315.        fprintf(stderr,"Initialization failed.\n");
  316.     }
  317.  
  318.     return(0); /* Finished, exit. */
  319.     }
  320.  
  321.    BUGS
  322.     None known.
  323.  
  324.    SEE ALSO
  325.  
  326.  
  327.  
  328. GAP.lib/Evolve                                                   GAP.lib/Evolve
  329.  
  330.    NAME
  331.     Evolve -- Performs generation shift on a population.
  332.     EvolveT -- Varargs interface to Evolve().
  333.  
  334.    SYNOPSIS
  335.     struct Population *Evolve(struct Population *,struct TagItem *);
  336.     struct Population *EvolveT(struct Population *,Tag,...);
  337.  
  338.     Pop = Evolve(Pop,TagList);
  339.     Pop = EvolveT(Pop,Tag0Type,...);
  340.  
  341.    FUNCTION
  342.     This is the big one. Evolve performs a generation shift, taking
  343.     a population and returning a new one.
  344.  
  345.    INPUTS
  346.     Pop    - Pointer to an initialized population structure.
  347.     TagList - Pointer to a taglist.
  348.  
  349.    TAGS
  350.     EVL_Evaluator (double (*)(void *)) - Pointer to a function taking
  351.          a pointer to an individual and returning its fitness value
  352.          as a double. Note well that this tag is _required_.
  353.          Also read the NOTE label further down.
  354.  
  355.     EVL_Mutator (void (*)(void *,int)) - Pointer to a mutator function
  356.          taking a pointer to an individual and its size. This function
  357.          should also decide if a mutation is to take place as it will be
  358.          called exactly once for every individual in the population. NULL
  359.          is a permitted value for this tag meaning that no mutation will
  360.          take place. The default is to use a built-in function designed to
  361.          mutate bitstrings.
  362.  
  363.     EVL_Crosser (void (*)(void *,void *,int)) - Pointer to a function which
  364.          performs crossover on two individuals. It should take two pointers
  365.          to individuals and their size and return nothing (void).
  366.          It will be called exactly once for every individual generated by
  367.          crossover. NULL is not a permitted value for this tag. The default
  368.          is to use a built-in function designed to perform crossover on two
  369.          bitstrings.
  370.  
  371.     EVL_Thermostat (double (*)(long,long)) - Pointer to a heat-regulating
  372.          function for Boltzmann selection (TEMPERATURE). The default
  373.          function is PopSize*(2.722-pow(1.0+1.0/Generation,Generation))
  374.          but this might change in later versions. The function takes
  375.          the size of the population as first argument and the generation
  376.          as second.
  377.  
  378.     EVL_Elite (int) - Sets the number of top individuals to copy from one
  379.          generation to the next without crossover (with the risk for
  380.          mutation though). Setting this value high will result in a
  381.          steady-state type of GA. The default value is 0.
  382.          Note!: Setting the Crowding flag currently alters the semantics of
  383.          this tag! If Crowding is in effect the Elite number is the number
  384.          of individuals not to generate. That is, in a population of
  385.          eg. 20 individuals an Elite value of 15 would mean generate
  386.          5 new individuals.
  387.  
  388.     EVL_Flags (unsigned long int) - Bulk initialization of flag tags
  389.          available flags are:
  390.  
  391.         FLG_InitDumped - Same as EVL_InitDumped
  392.         FLG_EraseBest  - Same as EVL_EraseBest
  393.         FLG_Crowding   - Same as EVL_Crowding
  394.         FLG_Statistics - Same as EVL_Statistics
  395.  
  396.          Example usage:  {EVL_Flags,FLG_Crowding|FLG_Statistics}
  397.          **NOTE** If using EVL_Flags, you must explicitly set
  398.          FLG_Statistics to generate statistics.
  399.  
  400.     EVL_Dump (int) - Sets the number of bottom (worst) individuals to dump
  401.          by replacing them with copies of the top (best) individuals.
  402.          Default is 0.
  403.  
  404.     EVL_Select (int) - Sets the select method used to determine parents
  405.          when generating new individuals. Available methods are:
  406.     
  407.         DRANDOM        :    Double-random selection. A random individual
  408.                 and one of those fitter than the first one
  409.                 selected are chosen. (Default)
  410.  
  411.         FITPROP        :    Fitness proportionate selection.
  412.  
  413.         SIGMA        :    Sigma scaled fitness proportionate selection.
  414.  
  415.         TOURNAMENT  :    Tournament selection (fast).
  416.  
  417.         INORDER        :    Inorder selection. The fittest individual is
  418.                 selected together with the rest in descending
  419.                 order of fitness.
  420.  
  421.         TEMPERATURE :    Boltzmann scaled selection. The selection
  422.                 pressure varies over time as determined by
  423.                 a 'heat' function. See also the EVL_Thermostat
  424.                 tag.
  425.  
  426.     EVL_Stats (BOOL) - Generate statistics. Generating statistics will
  427.          increase processing time significantly compared to not doing it.
  428.          If statistics are enabled, the fitness function might be called
  429.          twice as many times. Once for every old individual for evaluation
  430.          and once for every new individual for generating statistics.
  431.          This is dependant on caching and previous state. When caching is
  432.          disabled, then the fitness function will always be called exactly
  433.          twice if generating statistics. Default is TRUE.
  434.  
  435.     EVL_PreMutate (BOOL) - Mutate old generation instead of new. This
  436.          will mutate the parent population before generating new
  437.          individuals. Note that this is done after evaluation so that
  438.          setting this tag to TRUE will mean that there is no nessecary
  439.          connection between good genes and a high fitness - only a
  440.          probability thereof (depending on the mutator function). This
  441.          emulates mutation occuring in mature individuals in nature.
  442.  
  443.     EVL_Newbies (int) - Number of new individuals to generate. The
  444.          individuals to replace will be randomly selected from the old
  445.          population. This could for example be used to keep the fitness
  446.          of a population down when co-evolving populations.
  447.  
  448.     EVL_Mensurator (double (*)(void *,void *,int)) - Pointer to a function
  449.          taking two pointers to individuals and their sizes and returning
  450.          the absolute value of the distance (dissimilarity measure) between
  451.          them. Default is to measure the Hamming distance between
  452.          individuals.
  453.  
  454.     EVL_Crowding (BOOL) - Use crowding replacement where each new
  455.          individual generated replaces the individual most like itself.
  456.          Note! This tag currently alters the meaning of the EVL_Elite
  457.          tag!
  458.  
  459.     EVL_InitDumped (BOOL) - If dumping individuals (see EVL_Dump above)
  460.          initialize them instead of replacing them with copies of the
  461.          fittest indiviuals.
  462.  
  463.     EVL_EraseBest (BOOL) - If generating new random individuals (see 
  464.          EVL_Newbies tag above) replace the fittest individuals instead
  465.          of random ones.
  466.  
  467.    RESULT
  468.     Pop    - A pointer to the population structure or NULL is something
  469.           went horribly wrong.
  470.  
  471.    NOTE
  472.     Note that Evolve always treats higher fitness values as better,
  473.     this means that you must take care to transform your fitness
  474.     values accordingly if needed before returning them.
  475.  
  476.    BUGS
  477.     None currently known but if there are any major bugs, this is probably
  478.     where they are.
  479.  
  480.    SEE ALSO
  481.  
  482.  
  483. GAP.lib/Flip                                                       GAP.lib/Flip
  484.  
  485.    NAME
  486.     Flip -- Flip a bit in a bitstring.
  487.  
  488.    SYNOPSIS
  489.     void Flip(void *,int);
  490.  
  491.     Flip(Ind,At);
  492.  
  493.    FUNCTION
  494.     Flips a bit in a bitstring. Bits are counted from lower addresses to
  495.     higher.
  496.  
  497.    INPUTS
  498.     Ind    - A pointer to the bitstring (individual).
  499.     At    - The bit-position to be flipped.
  500.  
  501.    RESULT
  502.     None.
  503.  
  504.    BUGS
  505.     None known.
  506.  
  507.    SEE ALSO
  508.     Testbit()
  509.  
  510.  
  511. GAP.lib/GaussRand                                             GAP.lib/GaussRand
  512.  
  513.    NAME
  514.     GaussRand -- Generate a gaussian pseudo-random number.
  515.  
  516.    SYNOPSIS
  517.     double GaussRand(double,double);
  518.  
  519.     Val = GaussRand(My,Sigma);
  520.  
  521.    FUNCTION
  522.     Generates a pseudo random number around My with a Gaussian
  523.     distribution.
  524.  
  525.    INPUTS
  526.     My    - Value around which to generate a random number.
  527.  
  528.     Sigma    - Standard deviation of the generated numbers.
  529.  
  530.    RESULT
  531.     Val    - A random number.
  532.  
  533.    BUGS
  534.     None known.
  535.  
  536.    SEE ALSO
  537.     Rnd(), InitRand(), InRand()
  538.  
  539.  
  540. GAP.lib/HammingDist                                         GAP.lib/HammingDist
  541.  
  542.    NAME
  543.     HammingDist -- Measure the Hamming distance between two bitstrings.
  544.  
  545.    SYNOPSIS
  546.     unsigned long int HammingDist(void *,void *,int);
  547.  
  548.     distance = HammingDist(Ind1,Ind2,Size);
  549.  
  550.    FUNCTION
  551.     Counts the number of differings bits in two bitstrings.
  552.  
  553.    INPUTS
  554.     Ind1    - Pointer to the first bitstring (Individual)
  555.     Ind2    - Pointer to the second bitstring (Individual)
  556.     Size    - Number of _BYTES_ in each bitstring.
  557.    
  558.    RESULT
  559.     The number of differing bits.
  560.  
  561.    BUGS
  562.     None known.
  563.  
  564.    SEE ALSO
  565.  
  566.  
  567. GAP.lib/InitRand                                               GAP.lib/InitRand
  568.  
  569.    NAME
  570.     InitRand -- Initialize pseudo-random number generator.
  571.  
  572.    SYNOPSIS
  573.     void InitRand(long);
  574.  
  575.     InitRand(seed);
  576.  
  577.    FUNCTION
  578.     Initializes the internal pseudo-random number generator. This function
  579.     should be called with an appropriate seed before any of the random
  580.     number functions are called. Note that Evolve() also uses the random
  581.     number functions. A default seed is supplied but it is not recommended
  582.     to leave this as it is since every run will then be identical.
  583.  
  584.    INPUTS
  585.     seed    - A seed value for the pseudo random number generator.
  586.  
  587.    RESULT
  588.     None.
  589.  
  590.    EXAMPLE
  591.     #include <stdlib.h> /* For definition of NULL */
  592.     #include <time.h>
  593.     #include <GAP.h>
  594.     ...
  595.     int main(void)
  596.     {
  597.     ...
  598.     InitRand(time(NULL));
  599.     ...
  600.     return(0);
  601.     }
  602.  
  603.    BUGS
  604.     A seed value of 0 will not work properly.
  605.  
  606.    SEE ALSO
  607.     Rnd(), InRand(), GaussRand()
  608.  
  609.  
  610. GAP.lib/InRand                                                   GAP.lib/InRand
  611.  
  612.    NAME
  613.     InRand -- Generate a bounded floating point pseudo-random number.
  614.  
  615.    SYNOPSIS
  616.     double InRand(double,double);
  617.  
  618.     Val = InRand(Lo,Hi);
  619.  
  620.    FUNCTION
  621.     Generates a pseudo random number between Lo and Hi. The resolution of
  622.     the generated number is in steps of (Hi-Lo)/2147483646.
  623.  
  624.    INPUTS
  625.     Lo    - Lower bound of the range in which to generate a random
  626.           number.
  627.     Hi    - Upper bound of the range in which to generate a random
  628.           number.
  629.  
  630.    RESULT
  631.     Val    - A random number in the range [Lo,Hi] (inclusive).
  632.  
  633.    BUGS
  634.     None known.
  635.  
  636.    SEE ALSO
  637.     Rnd(), InitRand(), GaussRand()
  638.  
  639.  
  640. GAP.lib/IRange                                                   GAP.lib/IRange
  641.  
  642.    NAME
  643.     IRange -- Map an integer onto a range.
  644.  
  645.    SYNOPSIS
  646.     double IRange(unsigned long int,double,double);
  647.  
  648.     v = IRange(Val,Lo,Hi);
  649.  
  650.    FUNCTION
  651.     Maps an unsigned long integer onto the range [Lo,Hi] (inclusive).
  652.  
  653.    INPUTS
  654.     Val - The value to map.
  655.     Lo  - Lower bound of the range.
  656.     Hi  - Higher bound of the range.
  657.  
  658.    RESULT
  659.     v   - A value in the range [Lo,Hi].
  660.  
  661.    BUGS
  662.     None known.
  663.  
  664.    SEE ALSO
  665.     InRand()
  666.  
  667.  
  668. GAP.lib/PopMember                                             GAP.lib/PopMember
  669.  
  670.    NAME
  671.     PopMember -- Get the n:th member of a population.
  672.  
  673.    SYNOPSIS
  674.     void *PopMember(struct Population *,int);
  675.  
  676.     Ind = PopMember(Pop,n);
  677.  
  678.    FUNCTION
  679.     Returns a pointer to the n:th individual in a population (counted from
  680.     zero). For a population with say 50 individuals, valid numbers would
  681.     range from 0 to 49.
  682.  
  683.    INPUTS
  684.     Pop    - A pointer to an population structure.
  685.     n    - The number of the individual to retrieve.
  686.  
  687.    RESULT
  688.     Ind    - A pointer to the n:th individual in the population.
  689.  
  690.    BUGS
  691.     None known.
  692.  
  693.    SEE ALSO
  694.     CreatePopulation()
  695.  
  696.  
  697. GAP.lib/Rnd                                                         GAP.lib/Rnd
  698.  
  699.    NAME
  700.     Rnd -- Generate a pseudo-random integer.
  701.  
  702.    SYNOPSIS
  703.     long int Rnd(long int);
  704.  
  705.     Val = Rnd(Hi);
  706.  
  707.    FUNCTION
  708.     Generates a pseudo-random integer between zero and one less than Hi.
  709.     The random number generator is cyclic and repeats after 2147483645
  710.     generated numbers.
  711.  
  712.    INPUTS
  713.     Hi    - Upper bound of random number.
  714.  
  715.    RESULT
  716.     Val    - An integer in the range [0,Hi[.
  717.  
  718.    BUGS
  719.     Hi can not be greater than 2147483646 (0x7ffffffe = 2^31-1).
  720.     This means that Rnd() only gives 31 random bits, not 32.
  721.     Also, the random number algorithm 'sucks' so to speak.
  722.  
  723.    SEE ALSO
  724.     InRand(), InitRand(), GaussRand()
  725.  
  726.  
  727. GAP.lib/Testbit                                                 GAP.lib/Testbit
  728.  
  729.    NAME
  730.     Testbit -- Test the status of an arbitrary bit in a bitstring.
  731.  
  732.    SYNOPSIS
  733.     int Testbit(void *,int);
  734.  
  735.     status = Testbit(Ind,At);
  736.  
  737.    FUNCTION
  738.     Tests the status of a bit in a bitstring. Bits are counted from lower
  739.     addresses to higher.
  740.  
  741.    INPUTS
  742.     Ind    - A pointer to the bitstring.
  743.     At    - The number of the bit to be tested.
  744.  
  745.    RESULT
  746.     0 if the bit is clear, non-zero otherwise.
  747.  
  748.    BUGS
  749.     None known.
  750.  
  751.    SEE ALSO
  752.     Flip()
  753.  
  754.